<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

<%@ page import = "com.shopping.User" %>
  
<%@ page import = "com.shopping.exception.UserNameNotCorrectException"%>

<%@ page import = "com.shopping.exception.PasswordNotCorrectException" %>
  
  
  
<%

	String actionname = request.getParameter("action");
	if(actionname!=null && actionname.equals("login")){
		String username= request.getParameter("username");
		String password= request.getParameter("password");
		
		/*
		判断用户是否存在
		*/
		
		User u = null;
		try{
			 u = User.findUserCorrect(username,password);
		}catch(UserNameNotCorrectException e ){
			out.println("用户名不存在");
		}catch(PasswordNotCorrectException e ){
			out.println("密码不正确");
		}
		
		if(u!=null){
			session.setAttribute("user",u);
			response.sendRedirect("selfservice.jsp");
		}
	}

 %>
 
 
 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>用户登陆</title>
</head>
<body>


	<form action="login.jsp" method="post" name="loginform" style="text-align: center;">
	
		<input type="hidden" name="action" value="login">
		
		
		<table align="center">
			<tr>
				<td>
					用户名
				</td>
				<td>
					<input type="text" size="15" maxlength="15" name="username">
				</td>
			</tr>
		
			<tr>
				<td>
				密码
				</td>
				<td>
					<input type="password" size="15" maxlength="15" name="password">
				</td>
			</tr>
		
			<tr align="center">
				<td colspan="2">
					<input type="submit"  value="登陆">
					<input type="reset"  value="重置">
				</td>
			</tr>
		
		
		</table>
	</form>
</body>
</html>